package com.ws.servlet;
import javax.servlet.ServletConfig;

import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.frontend.ServerFactoryBean;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;

import com.ws.IHelloWorld;
import com.ws.impl.HelloWorldWs;
  
public class WebServlet extends CXFNonSpringServlet {  
//  private static final String SERVICE_SUFFIX = "";  
    private static final long serialVersionUID = 1L;    
        
    @Override    
    protected void loadBus(ServletConfig servletConfig) {    
        super.loadBus(servletConfig);    
          
        Bus bus = getBus();    
        BusFactory.setDefaultBus(bus);
        
        
        HelloWorldWs helloWorld = new HelloWorldWs();//实现类    
         
        ServerFactoryBean serverFactoryBean = new ServerFactoryBean(); //server工厂    
        serverFactoryBean.setServiceClass(IHelloWorld.class);// 接口类    
        serverFactoryBean.setAddress("/helloWorld"); //服务请求路径    
        serverFactoryBean.setServiceBean(helloWorld);    
        serverFactoryBean.create();    
    }    
}